﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Collections;
using System.Data;
using CE.Database;

/// <summary>
/// Summary description for CCApplicantDetailsDB
/// </summary>
/// 
namespace CE.CreditCard
{
    public class CCApplicantDetailsDB
    {
        public CCApplicantDetailsDB()
        {
            //
            // TODO: Add constructor logic here
            //
        }

        public CCApplicantDetails GetCCApplicantDetails(Int64 RefCEUserId)
        {
            CCApplicantDetails _ccApllicantDetail = null;
            MyDatabase _db = new MyDatabase();
            string _spName = "sprocCCApplicantDetailsSelectSingleItem";

            SortedList _spara = new SortedList();
            _spara.Add("@RefCEUserId", RefCEUserId);

            using (DataSet _ds = _db.GetDataSet(_spName, _spara))
            {
                if (_ds != null && _ds.Tables[0].Rows.Count > 0)
                {
                    _ccApllicantDetail = new CCApplicantDetails();
                    _ccApllicantDetail = FillDataRecord(_ds);
                }
            }
            return _ccApllicantDetail;
        }

        private CCApplicantDetails FillDataRecord(DataSet myDataSet)
        {
            CCApplicantDetails ApplicantDetails = new CCApplicantDetails();
            //Personnel
            ApplicantDetails.CCPersonnelId = Convert.ToInt64(myDataSet.Tables[0].Rows[0]["CCPersonnelId"].ToString());
            ApplicantDetails.CCARId = Convert.ToInt64(myDataSet.Tables[0].Rows[0]["CCCARId"].ToString());
            ApplicantDetails.CCSalutation = myDataSet.Tables[0].Rows[0]["CCSalutation"].ToString();
            ApplicantDetails.CCFirstName = myDataSet.Tables[0].Rows[0]["CCFirstName"].ToString();
            ApplicantDetails.CCSurName = myDataSet.Tables[0].Rows[0]["CCSurName"].ToString();
            ApplicantDetails.CCNameOfAppear = myDataSet.Tables[0].Rows[0]["CCNameOfAppear"].ToString();
            ApplicantDetails.CCNationality = myDataSet.Tables[0].Rows[0]["CCNationality"].ToString();
            ApplicantDetails.CCIdType = myDataSet.Tables[0].Rows[0]["CCIdType"].ToString();
            ApplicantDetails.CCIdNo = myDataSet.Tables[0].Rows[0]["CCIdNo"].ToString();
            ApplicantDetails.CCDOB = Convert.ToDateTime(myDataSet.Tables[0].Rows[0]["CCDOB"].ToString());
            ApplicantDetails.CCGender = Convert.ToChar(myDataSet.Tables[0].Rows[0]["CCGender"].ToString());
            ApplicantDetails.CCMaritalStatus = myDataSet.Tables[0].Rows[0]["CCMaritalStatus"].ToString();
            ApplicantDetails.CCNoOfDepent = Convert.ToInt32(myDataSet.Tables[0].Rows[0]["CCNoOfDependents"].ToString());
            ApplicantDetails.CCHighEdu = myDataSet.Tables[0].Rows[0]["CCHighestEdu"].ToString();
            ApplicantDetails.CCEmail = myDataSet.Tables[0].Rows[0]["CCEmail"].ToString();
            ApplicantDetails.CCMobileNo = myDataSet.Tables[0].Rows[0]["CCMobilePhoneNo"].ToString();
            ApplicantDetails.CCHomePhone = myDataSet.Tables[0].Rows[0]["CCHomePhoneNo"].ToString();
            ApplicantDetails.CCOfficePhone = myDataSet.Tables[0].Rows[0]["CCOfficePhoneNo"].ToString();
            ApplicantDetails.CCUnitNo = myDataSet.Tables[0].Rows[0]["CCUnitNo"].ToString();
            ApplicantDetails.CCHomeNo = myDataSet.Tables[0].Rows[0]["CCHomeNo"].ToString();
            ApplicantDetails.CCStreetName = myDataSet.Tables[0].Rows[0]["CCStreetName"].ToString();
            ApplicantDetails.CCCountry = myDataSet.Tables[0].Rows[0]["CCCountry"].ToString();
            ApplicantDetails.CCPostalCode = myDataSet.Tables[0].Rows[0]["CCPostalCode"].ToString();
            ApplicantDetails.CCYearsofThere = Convert.ToInt32(myDataSet.Tables[0].Rows[0]["CCYearsThere"].ToString());
            ApplicantDetails.CCEmergencyNo = myDataSet.Tables[0].Rows[0]["CCEmergencyNo"].ToString();
            ApplicantDetails.CCRelation = myDataSet.Tables[0].Rows[0]["CCEContactRelation"].ToString();
            ApplicantDetails.CCMailing = Convert.ToBoolean(myDataSet.Tables[0].Rows[0]["CCMailing"].ToString());
            ApplicantDetails.CCSupplementary = Convert.ToBoolean(myDataSet.Tables[0].Rows[0]["CCSupplementary"].ToString());

            //Employment
            ApplicantDetails.CCEmpId = Convert.ToInt64(myDataSet.Tables[1].Rows[0]["CCEmpId"].ToString());
            ApplicantDetails.CCEmpOccupation = myDataSet.Tables[1].Rows[0]["CCOccupation"].ToString();
            ApplicantDetails.CCIndBusiType = myDataSet.Tables[1].Rows[0]["CCIndBusType"].ToString();
            ApplicantDetails.CCEmpBusiName = myDataSet.Tables[1].Rows[0]["CCEmpBusName"].ToString();
            ApplicantDetails.CCEmpBusiNature = myDataSet.Tables[1].Rows[0]["CCEmpBusNature"].ToString();
            ApplicantDetails.CCPosition = myDataSet.Tables[1].Rows[0]["CCPosition"].ToString();
            ApplicantDetails.CCServiceYears = Convert.ToInt16(myDataSet.Tables[1].Rows[0]["CCServiceYears"].ToString());
            ApplicantDetails.CCServiceMonths = Convert.ToInt16(myDataSet.Tables[1].Rows[0]["CCServiceMonths"].ToString());
            ApplicantDetails.CCEmpUnitNo = myDataSet.Tables[1].Rows[0]["CCEmpUnitNo"].ToString();
            ApplicantDetails.CCEmpHomeNo = myDataSet.Tables[1].Rows[0]["CCEmpHomeNo"].ToString();
            ApplicantDetails.CCEmpStreetName = myDataSet.Tables[1].Rows[0]["CCEmpStreetName"].ToString();
            ApplicantDetails.CCEmpCountry = myDataSet.Tables[1].Rows[0]["CCEmpCountry"].ToString();
            ApplicantDetails.CCEmpPostalCode = myDataSet.Tables[1].Rows[0]["CCEmpPostalCode"].ToString();
            ApplicantDetails.CCAnualIncome = Convert.ToSingle(myDataSet.Tables[1].Rows[0]["CCAnualIncome"].ToString());
            ApplicantDetails.CCOtherIncome = Convert.ToBoolean(myDataSet.Tables[1].Rows[0]["CCOtherIncome"].ToString());
            ApplicantDetails.CCOtherIncomeAmt = Convert.ToSingle(myDataSet.Tables[1].Rows[0]["CCOtherIncomeAmount"].ToString());
            ApplicantDetails.CCOtherIncomeSource = myDataSet.Tables[1].Rows[0]["CCOtherIncomeSource"].ToString();

            //Supplementary
            if (myDataSet.Tables[2].Rows.Count > 0)
            {
                ApplicantDetails.CCSuppId = Convert.ToInt64(myDataSet.Tables[2].Rows[0]["CCSuppId"].ToString());
                ApplicantDetails.CCSuppSalutation = myDataSet.Tables[2].Rows[0]["CCSuppSalutation"].ToString();
                ApplicantDetails.CCSuppFirstName = myDataSet.Tables[2].Rows[0]["CCSuppFirstName"].ToString();
                ApplicantDetails.CCSuppSurName = myDataSet.Tables[2].Rows[0]["CCSuppSurName"].ToString();
                ApplicantDetails.CCSuppNameOfAppear = myDataSet.Tables[2].Rows[0]["CCSuppNameOfAppear"].ToString();
                ApplicantDetails.CCSuppRelation = myDataSet.Tables[2].Rows[0]["CCSuppRelation"].ToString();
                ApplicantDetails.CCSuppDOB = Convert.ToDateTime(myDataSet.Tables[2].Rows[0]["CCSuppDOB"].ToString());
                ApplicantDetails.CCSuppGender = Convert.ToChar(myDataSet.Tables[2].Rows[0]["CCSuppGender"].ToString());
                ApplicantDetails.CCSuppNationality = myDataSet.Tables[2].Rows[0]["CCSuppNationality"].ToString();
                ApplicantDetails.CCSuppIdType = myDataSet.Tables[2].Rows[0]["CCSuppIdType"].ToString();
                ApplicantDetails.CCSuppIdNo = myDataSet.Tables[2].Rows[0]["CCSuppIdNo"].ToString();
                ApplicantDetails.CCSuppEmail = myDataSet.Tables[2].Rows[0]["CCSuppEmail"].ToString();
                ApplicantDetails.CCSuppMobileNo = myDataSet.Tables[2].Rows[0]["CCSuppMobilePhoneNo"].ToString();
                ApplicantDetails.CCSuppHomePhone = myDataSet.Tables[2].Rows[0]["CCSuppHomePhoneNo"].ToString();
                ApplicantDetails.CCSuppOfficePhone = myDataSet.Tables[2].Rows[0]["CCSuppOfficePhoneNo"].ToString();
                ApplicantDetails.CCSuppUnitNo = myDataSet.Tables[2].Rows[0]["CCSuppUnitNo"].ToString();
                ApplicantDetails.CCSuppHomeNo = myDataSet.Tables[2].Rows[0]["CCSuppHomeNo"].ToString();
                ApplicantDetails.CCSuppStreetName = myDataSet.Tables[2].Rows[0]["CCSuppStreetName"].ToString();
                ApplicantDetails.CCSuppCountry = myDataSet.Tables[2].Rows[0]["CCSuppCountry"].ToString();
                ApplicantDetails.CCSuppPostalCode = myDataSet.Tables[2].Rows[0]["CCSuppPostalCode"].ToString();
            }
            return ApplicantDetails;
        }

    }
}